#pragma once



#include "qstring.h"
using namespace micro::utils;

#include<objidlbase.h>


namespace micro
{
namespace files
{


class  QAbstractFile: public IStream
{
   
public:

    QAbstractFile() {}
    virtual ~QAbstractFile() {}
    
     enum SeekPosition { begin = FILE_BEGIN, current = FILE_CURRENT, end = FILE_END };
    
    virtual HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void** ppvObject )
    {
        return S_FALSE;
    }
    
    virtual ULONG STDMETHODCALLTYPE AddRef( void )
    {
        return S_FALSE;
    }
    
    virtual ULONG STDMETHODCALLTYPE Release( void )
    {
        return S_FALSE;
    }
    
    //////////////////////////////////////////////////////////////////////////
    
    virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read( void* pv, ULONG cb, ULONG* pcbRead )
    {
        return S_FALSE;
    }
    
    virtual /* [local] */ HRESULT STDMETHODCALLTYPE Write( const void* pv, ULONG cb, ULONG* pcbWritten )
    {
        return S_FALSE;
    }
    //////////////////////////////////////////////////////////////////////////
    
    virtual /* [local] */ HRESULT STDMETHODCALLTYPE Seek( LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition )
    {
        return S_FALSE;
    }
    
    virtual HRESULT STDMETHODCALLTYPE SetSize( ULARGE_INTEGER libNewSize )
    {
        return S_FALSE;
    }
    
    virtual /* [local] */ HRESULT STDMETHODCALLTYPE CopyTo(
        /* [annotation][unique][in] */
        _In_  IStream* pstm,
        /* [in] */ ULARGE_INTEGER cb,
        /* [annotation] */
        _Out_opt_  ULARGE_INTEGER* pcbRead,
        /* [annotation] */
        _Out_opt_  ULARGE_INTEGER* pcbWritten )
    {
        return S_FALSE;
    }
    
    virtual HRESULT STDMETHODCALLTYPE Commit( DWORD grfCommitFlags )
    {
        return S_FALSE;
    }
    
    virtual HRESULT STDMETHODCALLTYPE Revert( void )
    {
        return S_FALSE;
    }
    
    virtual HRESULT STDMETHODCALLTYPE LockRegion( ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType )
    {
        return S_FALSE;
    }
    
    virtual HRESULT STDMETHODCALLTYPE UnlockRegion( ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType )
    {
        return S_FALSE;
    }
    
    virtual HRESULT STDMETHODCALLTYPE Stat( STATSTG* pstatstg, DWORD grfStatFlag )
    {
        return S_FALSE;
    }
    
    virtual HRESULT STDMETHODCALLTYPE Clone( IStream** ppstm )
    {
        return S_FALSE;
    }
    
    
    //////////////////////////////////////////////////////////////////////////
    virtual bool Open( LPCTSTR lpszFileName, UINT nOpenFlags, QError* pError = nullptr )
    {
        return false;
    }
    virtual void Close() = 0;
    virtual void Flush() = 0;
    
    virtual ULONGLONG GetPosition() const = 0;
    virtual ULONGLONG Seek( LONGLONG lOff, DWORD nFrom )    = 0;
    
    virtual LONGLONG GetFileSize() const = 0;
    virtual void SetFileSize( ULONGLONG nNewLen ) = 0;
    
    virtual ULONGLONG SeekToBegin()
    {
        return Seek( 0, begin );
    }
    virtual ULONGLONG SeekToEnd()
    {
        return Seek( 0, end );
    }
    
    
    virtual QString GetFilePath() const = 0;
    virtual size_t Read( void* lpBuf, size_t nCount ) = 0;
    virtual size_t Write( const void* lpBuf, size_t nCount ) = 0;
    virtual bool IsClosed() const = 0;
    
    
    
};






}
}//micro